package fhp.hlhj.giantfold.module

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.javaBean.BindPhoneBean
import fhp.hlhj.giantfold.javaBean.GetSmsBean
import fhp.hlhj.giantfold.network.UrlApis

/**
 * author: FHP
 * data: on 2018\1\18 0018 9:47
 * E-Mail: 103945089@qq.com
 */
class BindPhoneModule {
    interface BingdPhoneListener{
        fun showLoading()
        fun onBindListener(bindPhoneBean: BindPhoneBean)
        fun onSmsListener(getSmsBean: GetSmsBean)
    }

    /**
     * 获取验证码
     */
    fun getSms(params: HttpParams,listener: BingdPhoneListener){
        UrlApis.getSMSCode(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe {
                    data->
                    listener.onSmsListener(data)
                }
    }
    /**
     * 绑定手机
     */
    fun bindPhone(params: HttpParams,listener: BingdPhoneListener){
        UrlApis.bindPhone(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe {
                    data
                    ->
                    listener.onBindListener(data)
                }
    }
}